package com.aphrodite.ui.widgets.barcode;

import javax.microedition.lcdui.Font;

abstract class AbstractOutput implements Output {

	/** The background colour for drawing */
	int backgroundColour;
	/** The font to draw any text labels with. */
	final Font font;
	/** The foreground colour for drawing */
	int foregroundColour;
	/**
	 * Flag indicating whether the barcode will actually be outputted, or is
	 * just being sized.
	 */
	final boolean painting;
	/** The scaling factor to correctly size the barcode in the output units. */
	final double scalar;

	/**
	 * Populates this abstract outputter with common values.
	 * 
	 * @param font
	 *            The font to draw text labels with
	 * @param painting
	 *            Flag indicating whether painting will actually occur
	 * @param scalar
	 *            The scaling factor to size the barcode into the correct units
	 * @param foregroundColour
	 *            The colour to paint in
	 * @param backgroundColour
	 *            The background colour
	 */
	AbstractOutput(Font font, boolean painting, double scalar, int foregroundColour, int backgroundColour) {
		this.painting = painting;
		this.scalar = scalar;
		this.font = font;
		this.foregroundColour = foregroundColour;
		this.backgroundColour = backgroundColour;
	}

	/**
	 * Disables any drawing to the Output. Useful for sizing calculations.
	 */
	public void toggleDrawingColor() {
		int temp = foregroundColour;
		foregroundColour = backgroundColour;
		backgroundColour = temp;
	}
}
